<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script type="text/javascript">
 /*   fetch("/api/index.php?p=123").then(data => {
        return data.text();
    }).then(ret => {
        //要得到的最终数据
        console.log(ret)
    })*/
    fetch('/api/index.php', {
        method: 'post',
        body: 'uname=lisi&pwd=123',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    }).then(function (data) {
            return data.text();
        }).then(function (data) {
        console.log(data)
    });
    fetch('/api/index.php', {
        method: 'post',
        body: JSON.stringify({
            uname: '张三',
            pwd: '456'
        }),
        headers: {
            'Content-Type': 'application/json'
        }
    }).then(function (data) {
            return data.text();
        }).then(function (data) {
        console.log(data)
    });

</script>

</body>
</html>